package com.example.demo;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.reger.easemob.api.Easemob;

@SpringBootApplication
public class SpringBootStarterEasemobApplication  implements CommandLineRunner{
	Logger logger=LoggerFactory.getLogger(getClass());
	
	public static void main(String[] args) throws IOException {
		  SpringApplication.run(SpringBootStarterEasemobApplication.class, args); 
	}
	
	@Autowired private Easemob easemob;

	@Override
	public void run(String... arg0) throws Exception {
		String clientId="YXA6Irz_oI-GEead-FFvbfaMbQ";
		String clientSecret="YXA6VsR5JypETS3iPFvNNxYklmho0Vw";
		
		logger.info("{}",easemob.tokenApi.token(clientId, clientSecret));
		
		easemob.tokenApi.asyncToken(clientId,  clientSecret, (token)->{
			logger.info("{}",token);
		}, (error)->{
			logger.error("{}",error);
		});
	}
	
}
